<?php
class LayoutController extends Zend_Controller_Action{
	public function init(){
		if ($this->_helper->flashMessenger->hasMessages()) {
			$this->view->flashMessages = $this->_helper->flashMessenger->getMessages();
		}
		//tắt layout
		$this->_helper->layout()->disableLayout(true);
	}
	
	public function indexAction(){
		
	}
	
	public function headerAction(){
		$model = new Application_Model_DbTable_Site();
		$setting = $model->fetchRow($model->select()->where('site_name = ?','default'));
		$this->view->setting = $setting;
	}
	
	public function footerAction(){
		$mdConstant = new Application_Model_DbTable_Constant();
		$constantContent = $mdConstant->fetchRow($mdConstant->select()->where('constant_code = ?','default_footer_content'));
		$this->view->constantContent = $constantContent;
	}
	
	public function searchAction(){
		$manufactureMD = new Application_Model_DbTable_Manufacture();
		$manufactures = $manufactureMD->getPairColumn();
		$this->view->manufactures = $manufactures;
	}
	
	public function sidebarAction(){
	   //QUẢNG CÁO
       	$mdAdvertisement = new Application_Model_DbTable_Advertisement();
		$select = $mdAdvertisement->select()->where('advertisement_status = 1')
			->where('advertisement_advertisement_category_id = 2');
		$list = $mdAdvertisement->fetchAll($select);
		$this->view->listAdvSidebarRight = $list;
        
        
	   //tin tức
		$mdNews = new Application_Model_DbTable_News();
        $filters = array('status'=>1,'limit'=>10);
        $listNews = $mdNews->getList($filters);
        $this->view->listNews = $listNews;
	}
	
	public function sliderAction(){
		$mdAdvertisement = new Application_Model_DbTable_Advertisement();
		$select = $mdAdvertisement->select()->where('advertisement_status = 1')
			->where('advertisement_advertisement_category_id = 1');
		$list = $mdAdvertisement->fetchAll($select);
		$this->view->list = $list;
	}
	
	public function navigationAction(){
		
	}
	
	public function alertAction(){

		$this->_helper->layout()->enableLayout(true);
		$this->view->layout()->placeholders = array(
				'slider'=>array('status'=>false,'content'=>""),
				'search'=>array('status'=>false,'content'=>"")
		);;
	}
}
